﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.WpfShell.Utils
{
    public static class ArgumentsUtil
    {
        public static Dictionary<string, string> Prase(string arguments)
        {
            Dictionary<string, string> args = new Dictionary<string,string>();

            string[] argArray = arguments.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string arg in argArray)
            {
                string[] argData = arg.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                if (argData.Length == 2)
                {
                    string argKey = argData[0].Trim();
                    string argValue = argData[1].Trim();

                    if (!args.ContainsKey(argKey))
                    {
                        args.Add(argKey, argValue);
                    }
                }
            }
            return args;
        }
    }
}
